{
LANG : PASCAL
PROB : lamps
}

program LAMPS;
const
  fi = 'lamps.in';
  fo = 'lamps.out';
  max = 100;
var
  a, d : array[1..max] of shortint;
  p : array[1..4] of byte;
  ans : array[1..max] of string;
  n, c, l, sum : longint;

procedure inp;
var
  k : integer;
begin
  readln(n);
  readln(c);
  if c > 4 then
    if odd(c) then c:= 3
    else c := 4;
  fillchar(d, sizeof(d), $FF);
  read(k);
  while k <> -1 do
  begin
    d[k] := 1;
    read(k);
  end;
  readln;
  read(k);
  while k <> -1 do
  begin
    d[k] := 0;
    read(k);
  end;
end;

procedure push;
var
  i : integer;
begin
  inc(l);
  for i := 1 to n do
    if a[i] = 1 then ans[l] := ans[l] + '1'
    else ans[l] := ans[l] + '0';
end;

procedure change(k : integer);
var
  i : integer;
begin
  case k of
    1 : for i := 1 to n do a[i] := a[i] xor 1;
    2 : for i := 1 to n do
          if i and 1 = 1 then a[i] := a[i] xor 1;
    3 : for i := 1 to n do
          if i and 1 = 0 then a[i] := a[i] xor 1;
    4 : for i := 1 to n do
          if i mod 3 = 1 then a[i] := a[i] xor 1;
  end;
end;

function ok : boolean;
var
  i : integer;
begin
  ok := false;
  for i := 1 to n do
    if (d[i] <> -1) and (a[i] <> d[i]) then exit;
  ok := true;
end;

procedure try(k : integer);
begin
  if sum > c then exit;
  if k = 5 then
  begin
    if (sum and 1 = c and 1) and ok then push;
    exit;
  end;
  p[k] := 0;
  try(k+1);
  p[k] := 1;
  inc(sum);
  change(k);
  try(k+1);
  change(k);
  dec(sum);
end;

procedure sort;
var
  i, j : integer;
  temp : string;
begin
  for i := 1 to l do
    for j := i+1 to l do
      if ans[i] > ans[j] then
      begin
        temp := ans[i];
        ans[i] := ans[j];
        ans[j] := temp;
      end;
end;

procedure process;
begin
  fillchar(a, sizeof(a), 1);
  sum := 0;
  l := 0;
  try(1);
  sort;
end;

procedure out;
var
  i : integer;
begin
  if l = 0 then writeln('IMPOSSIBLE')
  else
    for i := 1 to l do writeln(ans[i]);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  out;
  close(output);
  close(input);
end.